package ordnerShuffle;

import java.io.File;
import java.io.IOException;
import java.util.Vector;

public class Shuffle {

	/**
	 * @param args
	 * @throws IOException
	 */

	public Shuffle() throws IOException {

		File dir = getDir();
		File[] list = dir.listFiles();
		Vector<Integer> used = new Vector<Integer>();
		String end = "";
		int rand = 0;

		for (File f : list) {

			if (f.isFile() && !f.getName().equals("Shuffle.jar")) {
				end = f.getName().substring(f.getName().lastIndexOf("."));

				do {
					rand = (int) (Math.random() * list.length * 3);
				} while (used.contains(rand));

				used.add(rand);

				f.renameTo(new File(f.getCanonicalPath().substring(0,
						f.getCanonicalPath().lastIndexOf("\\"))
						+ File.separatorChar + rand + end));
			}
		}
		
		System.out.println("Done");

	}


	private File getDir() {

		// return new File(java.lang.System.getProperty("user.dir"));
		return new File("C:\\Users\\Marvin\\Pictures\\Wallpaper\\Anime");
	}

	public static void main(String[] args) throws IOException {
		new Shuffle();

	}

}
